package server

import (
	"codeforces/src/task"
	"net/http"
)

func fetch(inChan chan task.ITask, outChan chan task.ITask) {
	for task := range inChan {
	redo:
		resp, err := http.Get(task.URL())
		if err != nil {
			if task.RetryAble() {
				goto redo
			} else {
				task.SetErr(err)
				outChan <- task
			}
		} else {
			task.SetReader(resp.Body)
			outChan <- task
		}

	}

}
